package com.myk.game.sumeru.data;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.ArrayMap;

import com.myk.game.lib.utils.BitmapUtil;

import java.util.Map;

public class ImageDataPool {

    private final Map<String, Bitmap> imageMap;
    private final Context context;

    public ImageDataPool(Context context) {
        this.context = context;
        imageMap = new ArrayMap<>();
    }

    public Bitmap getResBitmap(int resId, int width, int height) {
        String key = "" + resId + width + height;
        if (imageMap.get(key) == null) {
            imageMap.put(key, BitmapUtil.getBitmap(context, resId, width, height));
        }
        return imageMap.get(key);
    }
}
